#include <stdio.h>
void reduce(int numerator, int denominator,
            int *reduced_numerator, int *reduced_denominator);
int main(void)
{
    int top, bottom, reduced_top, reduced_buttom;
    printf("Enter a faction: ");
    scanf("%d /%d", &top, &bottom);
    reduce(top, bottom, &reduced_top, &reduced_buttom);
    if (reduced_buttom == 1)
        printf("In lowest terms: %d\n", reduced_top);
    else
        printf("In lowest terms: %d/%d\n", reduced_top, reduced_buttom);
    return 0;
}
void reduce(int numerator, int denominator,
            int *reduced_numerator, int *reduced_denominator) 
{
    *reduced_numerator = numerator;
    *reduced_denominator = denominator;
    if (denominator < numerator) {
        denominator = denominator + numerator;
        numerator = denominator - numerator;
        denominator = denominator - numerator;
    }
    while (numerator != 0) {
        denominator = denominator % numerator;
        denominator = denominator + numerator;
        numerator = denominator - numerator;
        denominator = denominator - numerator;
    }
    *reduced_numerator /= denominator;
    *reduced_denominator /= denominator;
}